<?php
require 'spl.php';

function required_valid($str_1, $str_2) {
    //初始化

    $Parameters = new \liyuze\Parameters\Parameters();
    //配置参数和验证规则
    $Parameters->config([
        'str_1' => [$str_1, ['required'] ],
        //自定义是否为空验证规则
        'str_2' => [$str_2, ['required', 'isEmpty' => function($value) {
            return $value === null;
        }]],
    ], true);

    //验证
    $Parameters->validate();

    return $Parameters->getErrors();
}

function test_pass()
{
    $str_1 = null;
    $str_2 = '';
    $r = required_valid($str_1, $str_2);
    return json_encode($r, 256);
}

function test_string()
{
    $str_1 = 55555;
    $str_2 = '55555';
    $r = required_valid($str_1, $str_2);
    return json_encode($r, 256);
}


var_dump(
    test_pass(),
    test_string()
);

